/*******************************************************************************
 * 版权：北京润尼尔网络科技有限公司，保留所有版权<br>
 * 版本：v1.0.0<br>
 * 文件：EditPartDefine.js<br>
 * 日期：2016年10月12日<br>
 * 作者: 王志远<br>
 * 功能：测试EditPart定义文件<br>
 * 
 * 修改记录：<br>
 * 日期 描述 更新功能<br>
 ******************************************************************************/

window.makeNamespace(window,"Rainier.UI.V2.Circuit.Ac");

//EditPart创建工厂
Rainier.UI.V2.Circuit.Ac.PartFactory = Rainier.UI.V2.PartFactory.extend({
    NAME : "Rainier.UI.V2.Circuit.Ac.PartFactory",
    
    init : function(){
        this._super();
        this.classMap = new draw2d.util.ArrayList();
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","DualChannelOscilloscope","Rainier.UI.V2.Virtual.DualChannelOscilloscope");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","FourChannelOscilloscope","Rainier.UI.V2.Virtual.FourChannelOscilloscope");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","TekOscilloscope","Rainier.UI.V2.Virtual.TekOscilloscope");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","FrequencyCounter","Rainier.UI.V2.Virtual.FrequencyCounter");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","SpectrumAnalyzer","Rainier.UI.V2.Virtual.SpectrumAnalyzer");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","VoltageProbe","Rainier.UI.V2.Virtual.VoltageProbe");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","SignalGeneratorAFG2005","Rainier.UI.V2.Virtual.SignalGeneratorAFG2005Action");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","BodePlot","Rainier.UI.V2.Virtual.BodePlotAction");
        this.register("Rainier.UI.V2.DSVirtualModel","Rainier.UI.V2.VirtualEditPart","DCVoltmeter","Rainier.UI.V2.Virtual.DCVoltmeterAction");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","DifferentialVoltageProbe","Rainier.UI.V2.Virtual.DifferentialVoltageProbeAction");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","VictoryMultimeterVC9802A","Rainier.UI.V2.Virtual.VictoryMultimeterVC9802AAction");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","EightChannelOscilloscope","Rainier.UI.V2.Virtual.EightChannelOscilloscopeAction");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","ACammeter","Rainier.UI.V2.Virtual.ACammeterAction");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","ACvoltmeter","Rainier.UI.V2.Virtual.ACvoltmeterAction");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","DCammeter","Rainier.UI.V2.Virtual.DCammeterAction");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","CurrentClamp","Rainier.UI.V2.Virtual.CurrentClampAction");
        this.register("Rainier.UI.V2.VirtualModel","Rainier.UI.V2.VirtualEditPart","Wattmeter","Rainier.UI.V2.Virtual.WattmeterAction");
    },
    
    register : function(sModelClassName,sEditPartClassName,sLabel,sJson){
    	
    	var deviceLabel = [];
    	this.classMap.each(function(index,deviceInfo){
    		var label = deviceInfo.label;
    		deviceLabel.push(label);
    	});
    	if(deviceLabel.indexOf(sLabel) === -1){    		
    		var map = {};
    		map.modelClassName 		= sModelClassName;
    		map.editPartClassName 	= sEditPartClassName;
    		map.label 				= sLabel;
    		map.json				= sJson;
    		this.classMap.add(map);
    	}
    	
    },
    
    getRegisteredClassMap : function(){
    	return this.classMap;
    },
    
    createObject : function(objModel){
    	var obj = this._super(objModel);
    	if(obj){
    		return obj;
    	}
    	
    	var editPartClassName  = null;
    	this.classMap.each(function(i,map){
    		if(map.modelClassName === objModel.NAME){
    			editPartClassName  = map.editPartClassName;
    		}
    	});
    	
    	if(editPartClassName){
    		return eval("new " + editPartClassName + "();");
    	}
    	return null;
    },
});